package org.springframework.prospring.ticket.web.controllers;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.prospring.ticket.service.RegionManager;
import org.springframework.prospring.ticket.service.ProvinceManager;
import org.springframework.prospring.ticket.domain.location.Province;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.List;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Alexis Quiros
 * Date: 12/02/2009
 * Time: 15:30:37
 * To change this template use File | Settings | File Templates.
 */
public class AdvancedFilterController implements Controller {

    // the Province manager service this controller uses.
    private ProvinceManager provinceManager;


    public ProvinceManager getProvinceManager() {
        return provinceManager;
    }

    public void setProvinceManager(ProvinceManager provinceManager) {
        this.provinceManager = provinceManager;
    }

    public ModelAndView handleRequest(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

        System.out.println("======================= AdvancedFilterController.handleRequest");
        String aMessage = "Esta por realizar un filtro avanzado!";

        Collection<Province> provinces = provinceManager.findAllProvinces();

        ModelAndView modelAndView = new ModelAndView("advancedFilterViewName");
        modelAndView.addObject("message", aMessage);
        modelAndView.addObject("provinces", provinces);

        return modelAndView;
    }
}
